<?php
// -----------------------------------------------------------------------------
// include
// -----------------------------------------------------------------------------

include "../config/config.php";
include "../auth.php";
include "../DBManager.php";

// -----------------------------------------------------------------------------
// 访问相关设置
// -----------------------------------------------------------------------------

if (!isset($_GET["source"]) || !isset($_GET["target"]) || !isset($_GET["action"])) {
    exit("需要传入有效的参数！");
}

$source = $_GET["source"];
$target = $_GET["target"];
$action = $_GET["action"];

// -----------------------------------------------------------------------------
// 时区设置
// -----------------------------------------------------------------------------

date_default_timezone_set($region);
$now = (string)time();

// -----------------------------------------------------------------------------
// 数据库相关设置
// -----------------------------------------------------------------------------

$dbPath = "../" . $dbPath; // 不加这行语句的话会报错，提示找不到对应路径
$db = new DBManager("sqlite:" . $dbPath);

// -----------------------------------------------------------------------------

if ($action == "under") {

    // 移动到最下方的链接的下方时，获取到的值是 undefined
    if ($target == "undefined") {
        $target = $now;
    }

}
$db->changeSortNumberOfLinkFromAToB($source, $target);
